package com.ruide.db;

import java.beans.PropertyVetoException;
import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;

import com.mchange.v2.c3p0.ComboPooledDataSource;

public class DBHelper {
	public static String DRIVER;
	public static String URL;
	public static String USER;
	public static String PASSWORD;
	public static ComboPooledDataSource cpds=null;
	static{
		Properties pro=new Properties();
		InputStream in=DBHelper.class.getClassLoader().getResourceAsStream("db.properties");
		try {
			pro.load(in);
		} catch (IOException e) {
			e.printStackTrace();
		}
		DRIVER=pro.getProperty("DRIVER");
		URL=pro.getProperty("URL");
		USER=pro.getProperty("USER");
		PASSWORD=pro.getProperty("PASSWORD");
		cpds=new ComboPooledDataSource();
		try {
			cpds.setDriverClass(DRIVER);
		} catch (PropertyVetoException e) {
			e.printStackTrace();
		}
		cpds.setJdbcUrl(URL);
		cpds.setUser(USER);
		cpds.setPassword(PASSWORD);
		cpds.setInitialPoolSize(20);
		cpds.setAcquireIncrement(5);
		cpds.setMaxPoolSize(100);
	}
}
